package com.sky.mapper;

import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishFlavorMapper {
    /**
     * 添加菜品口味
     *
     * @param flavors
     */
    void saveDishFlavor(@Param("flavors") List<DishFlavor> flavors);

    /**
     * 删除菜品原有口味
     *
     * @param id
     */
    @Delete("DELETE FROM dish_flavor WHERE dish_id = #{id}")
    void deleteDishFlavorByDishId(Long id);

    /**
     * 删除菜品口味
     *
     * @param ids
     */
    void deleteDishFlavorByDishIds(@Param("ids") List<Long> ids);

    /**
     *
     * @param id
     * @return
     */
    @Select("select * from dish_flavor where dish_id=#{id};")
    List<DishFlavor> listByDishId(Long id);

    /**
     * 根据菜品ID查询口味
     * @param id
     * @return
     */
    @Select("select * from dish_flavor where dish_id=#{id};")
    List<DishFlavor> selectDishFlavorByDishId(Long id);
}
